import Vue from 'vue'

Vue.filter('filterImg', function(path) {
  return process.env.VUE_APP_IMG_SERVER + path
})

Vue.filter('test', function(input) {
  return input + 'test'
})

Vue.filter('dateFilter', function(input) {
  const d = new Date(input)
  const year = d.getFullYear()
  const month = d.getMonth() < 9 ? '0' + (d.getMonth() + 1) : '' + (d.getMonth() + 1)
  const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  return (year + '-' + month + '-' + day)
})

Vue.filter('categoryFilter', function(index) {
  switch (index) {
    case '1':
      return '电影'
    case '2':
      return '电视剧'
    case '3':
      return '动漫'
    case '4':
      return '综艺'
    default:
      return '未知'
  }
})

Vue.filter('datetimeFilter', function(input) {
  const d = new Date(input)
  const year = d.getFullYear()
  const month = d.getMonth() < 9 ? '0' + (d.getMonth() + 1) : '' + (d.getMonth() + 1)
  const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours()
  const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes()
  const seconds = d.getSeconds() < 10 ? '0' + d.getSeconds() : '' + d.getSeconds()
  return (year + '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds)
})

Vue.filter('dramaStatusFilter',function (status) {
  const statusMap = {
    '1': '完结',
    '0': '连载',
    '-1': '未开播'
  }
  return statusMap[status]
})
